package com.wsk.api.controller;

import com.wsk.api.bean.SimpleUser;
import com.wsk.api.bean.User;
import com.wsk.api.bean.UserEnum;
import com.wsk.api.service.ManagerUser;
import com.wsk.api.service.UserLogin;
import org.springframework.context.support.ClassPathXmlApplicationContext;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;

/**
 * @DESCRIPTION :
 * @AUTHOR : WuShukai1103
 * @TIME : 2017/12/9  22:13
 */
@Controller
public class ManagerUserController {
//    @Autowired
    private UserLogin login;

//    @Autowired
    private ManagerUser managerUser;

    @RequestMapping(value = "save")
    public String save(Model model) {
        ClassPathXmlApplicationContext context =
                new ClassPathXmlApplicationContext("consumer.xml");
        context.start();
        User user = new SimpleUser();
        user.setId("18814095631");
        user.setPassword("123456");
        user.setUserEnum(UserEnum.Simple);
        managerUser = (ManagerUser) context.getBean("managerService");
        managerUser.save(user);
        model.addAttribute("user", user);
        return "success";
    }
    @RequestMapping(value = "")
    public String index(){
        return "index";
    }
}
